angular.module('confirmOrderModule',[])
    .controller('confirmOrderCtr',['$scope','checkLoginFactory','httpFactory','$filter','$location',function($scope,checkLoginFactory,httpFactory,$filter,$location){
        checkLoginFactory.checkLogin();
        $scope.goBack=function(){
            window.history.back();
        };
        $scope.userName=LsyCookie.getItem('userLogin');
        $scope.total=0;
        $scope.num=0;
        var confirmOrderData=LsyStorage.getItem('confirmOrderDatas');
        httpFactory.getData('./src/datas/proData.json')
            .then(function (data) {
                $scope.newDatas = $filter('getShopCartFilter')(data, confirmOrderData);
                $scope.num=$scope.newDatas.length;
                angular.forEach($scope.newDatas,function(item){
                    $scope.total+=item.price*item.num;
                })
            });
        $scope.pay=function(){
            LsySession.setItem('totalPrice',$scope.total);
            $location.path('pay');
        }
    }]);
